import type { SogouElements } from '../../../../../../../../types/constants/personalization/sogou'
import type { ThemeType } from '../../../../../../../../types/interfaces'
import { IconService } from '../../../../../../../../lib/icons'
import { ICON_IDS } from '../../../../../../../../lib/icons/types/constants'
import { PAGE_ELEMENTS, SUPPORTED_PLATFORMS } from '../../../../../../../../types/constants'
import { SogouCommonPage } from './common'

export class SogouZhihuPage {
  elements: SogouElements = PAGE_ELEMENTS[SUPPORTED_PLATFORMS.SO_GOU]
  private static instance: SogouZhihuPage
  private iconService: IconService = IconService.getInstance()
  private commonPage: SogouCommonPage = SogouCommonPage.getInstance()

  /**
   * 获取单例实例
   */
  public static getInstance(): SogouZhihuPage {
    if (!SogouZhihuPage.instance) {
      SogouZhihuPage.instance = new SogouZhihuPage()
    }
    return SogouZhihuPage.instance
  }

  init(): void {
  }

  /**
   * 无搜索结果样式
   */
  noSearchResult(): string {
    return ``
  }

  getMainStyles(theme: ThemeType): string {
    return `
${this.commonPage.baseWebResultStyles(theme)}

#sogou_wrap_id #wrapper #main .results > .vrwrap {
  /* 赞 */
  .zan-box {
    &::before {
      background-image: ${this.iconService.api.icon.asDataUrl(ICON_IDS.rating.good, { theme })} !important;
      background-size: contain !important;
      background-repeat: no-repeat !important;
      background-position: unset !important;
    }
  }
}
`
  }
}
